<template>
  <van-picker
    title="改变性别"
    show-toolbar
    :columns="columns"
    @confirm="onConfirm"
    @cancel="onCancel"
    :default-index="useaGender"
  />
</template>

<script>
import { changeInfo } from '@/api'
export default {
  props: {
    useaGender: {
      type: [Number, String],
      require: true
    }
  },
  data() {
    return {
      columns: ['男', '女']
    }
  },
  methods: {
    async onConfirm(value, index) {
      await changeInfo({ gender: index })
      //修改视图
      this.$emit('update:useaGender', index)
      //关闭窗口
      this.$emit('chagesex')
    },
    onCancel() {
      this.$emit('chagesex')
    }
  }
}
</script>

<style></style>
